package com.zhengbing.tj.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zhengbing.tj.entity.UserRole;
import com.zhengbing.tj.mapper.UserRoleMapper;
import com.zhengbing.tj.service.UserRoleService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 用户角色关联服务实现类
 * 处理用户角色关联实体的具体业务逻辑
 *
 * @author zhengbing
 * @date 2024-08-22
 */
@Service
public class UserRoleServiceImpl extends ServiceImpl<UserRoleMapper, UserRole> implements UserRoleService {
    
    @Override
    public boolean removeByUserId(Long userId) {
        QueryWrapper<UserRole> wrapper = new QueryWrapper<>();
        wrapper.eq("user_id", userId);
        return remove(wrapper);
    }
    
    @Override
    public boolean removeByRoleId(Long roleId) {
        QueryWrapper<UserRole> wrapper = new QueryWrapper<>();
        wrapper.eq("role_id", roleId);
        return remove(wrapper);
    }
    
    @Override
    public List<Long> selectRoleIdsByUserId(Long userId) {
        return getBaseMapper().selectRoleIdsByUserId(userId);
    }
}